//
//  CenterHeadView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/9/10.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class CenterHeadView: UIView {

    fileprivate let imageView  = UIImageView()
    fileprivate let titleLabel = UILabel()
    fileprivate let numberLabel = UILabel()
    
    var image : UIImage! {
        didSet{
            imageView.image = image
        }
    }
    
    var title : String! {
        didSet{
            titleLabel.text = title + recommend_title
        }
    }
    
    var text : String! {
        didSet{
            numberLabel.text = "为您找到" + text + "张符合条件的卡"
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        let headView = UIView()
        headView.backgroundColor = UIColor.white
        self.addSubview(headView)
        
        headView.addSubview(imageView)
        
        titleLabel.textColor = UIColor.red
        titleLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 18))
        headView.addSubview(titleLabel)
        
        numberLabel.backgroundColor = UIColor.mineColor()
        numberLabel.textAlignment = .center
        numberLabel.textColor = UIColor.lightGray
        numberLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        headView.addSubview(numberLabel)
        
        headView.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(RATIO_H(maxNum: 40))
        }
        
        imageView.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(RATIO(maxNum: 8))
            make.width.height.equalTo(RATIO_H(maxNum: 30))
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(imageView.snp.right).offset(RATIO(maxNum: 8))
            make.centerY.equalTo(imageView)
            make.height.equalToSuperview()
            make.width.greaterThanOrEqualTo(10)
        }
        
        numberLabel.snp.makeConstraints { (make) in
            make.top.equalTo(headView.snp.bottom)
            make.left.right.equalToSuperview()
            make.height.equalTo(RATIO_H(maxNum: 40))
        }
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
